<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>新闻列表</title>
		<meta name="viewport" content="initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" href="//cdn.bootcss.com/weui/0.4.3/style/weui.min.css">
		<link rel="stylesheet" href="//cdn.bootcss.com/jquery-weui/0.8.3/css/jquery-weui.min.css">
		<link rel="stylesheet" href="../css/index.css" />
	</head>

	<body id="presslist">
		<ul>
			<!--<a href="presslistdetails.html">
			<li>
				<img src="../img/news.png" />
				<p>杭州万象物业服务处职工积极参加无偿献血</p>
				<span><img src="../img/xgz.png"/>288</span>
				<b>2017-04-15 12:30</b>
				<div class="clear"></div>
			</li>
			</a>
			<li>
				<img src="../img/news.png" />
				<p>杭州万象物业服务处职工积极参加无偿献血</p>
				<span><img src="../img/xgz.png"/>288</span>
				<b>2017-04-15 12:30</b>
				<div class="clear"></div>
			</li>
			<li>
				<img src="../img/news.png" />
				<p>杭州万象物业服务处职工积极参加无偿献血</p>
				<span><img src="../img/xgz.png"/>288</span>
				<b>2017-04-15 12:30</b>
				<div class="clear"></div>
			</li>
			<li>
				<img src="../img/news.png" />
				<p>杭州万象物业服务处职工积极参加无偿献血</p>
				<span><img src="../img/mgz.png"/>288</span>
				<b>2017-04-15 12:30</b>
				<div class="clear"></div>
			</li>
			<li>
				<img src="../img/news.png" />
				<p>杭州万象物业服务处职工积极参加无偿献血</p>
				<span><img src="../img/mgz.png"/>288</span>
				<b>2017-04-15 12:30</b>
				<div class="clear"></div>
			</li>-->
		</ul>
		<div class="weui-infinite-scroll loading">
			  <div class="infinite-preloader"></div>
			  正在加载中... 
		</div>
		<script src="//cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
		<script src="//cdn.bootcss.com/jquery-weui/0.8.3/js/jquery-weui.min.js"></script>
		<script type="text/javascript" src="../js/basic.js"></script>
		<script>
			var ip_addr = getUrl();
			var pageNo = 1;
			var pageSize = 8;
			var loading = false;
			$(document).ready(function() {
				newslist();
				$("#presslist").infinite().on("infinite", function() {
					 if(loading) return;
					  loading = true;
					  setTimeout(function() {
					    pageNo++; 
					    newslist();;
					    loading = false;
					  }, 800); 
				});
			});
			//新闻列表接口
			function newslist() {
				var type = GetQueryString("type")
				$.ajax({
					type: 'post',
					dataType: "json",
					url: ip_addr + 'news/list',
					data: {
						type: type,
						pageNo: pageNo,
						pageSize: pageSize
					},
					success: function(data) {
						var result = data.rows;
						var innerHTML = '';
						if(data.total <= pageNo*pageSize){
							loading = true;
							$(".loading").hide();
						}else{
							loading = false;
						}
						if(data.total < 8){
							$(".loading").hide();
						}
						if(data.code == 0) {
							for(var i = 0; i < result.length; i++) {
								innerHTML += '<a href="presslistdetails.html?id='+result[i].id+'">';
								innerHTML += '<li>';
								innerHTML += '<img src="'+result[i].img.replace('../',"")+'" />';
								innerHTML += '<p>'+result[i].title+'</p>';
//								innerHTML += '<span><img src="../img/xgz.png"/>'+result[i].collNum+'</span>';
								innerHTML += '<b>'+formatDateM(result[i].updateTime)+'</b>';
								innerHTML += '<div class="clear"></div>';
								innerHTML += '</li>';
								innerHTML += '</a>';
							}
							$("#presslist ul").append(innerHTML);
						} else {
							$.alert({
							  title: '温馨提示',
							  text: '很抱歉，您还未登录，请登录!',
							  onOK: function () {
							   window.location.href = 'wode.html?type=1';
							  }
							});
						}
					}
				});
			}
		</script>
	</body>

</html>